struct Block{
	unsigned long size;
	bool allocated;
	bool split;
	Block *parent;
	Block *left;
	Block *right;
	void *location;

	Block(): size(0), left(NULL), right(NULL), allocated(false), split(false) {};
};

class Buddy{
public:
	Buddy(unsigned long);
	~Buddy();
	Block * my_malloc(unsigned long);
	void printTree();
	void my_free(Block *);

private:
	Block *root;
	Block *min;
	Block * findMin(unsigned long);
	Block * split(Block *);
	int memAllocated;
	void *memPtr;
};
